/*
 * Aiming.cpp
 *
 *  Created on: 2012/07/07
 *      Author: weihe
 */

#include "Aiming.h"
#include "utility.h"
#include <gl/glut.h>

namespace object {

Aiming::~Aiming()
{
}

void Aiming::draw()
{
	static int id = -1;
	Point2f center = window.center();
	glPushMatrix();
	{
		glEnable(GL_LINE_SMOOTH);
		glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
		glTranslatef(center.x, center.y, 0);
		if (id == -1) {
			id = glGenLists(2);
			glNewList(id, GL_COMPILE);
			{
				glColor3f(1.0, 0.0, 0.0);
				glBegin(GL_LINE_LOOP);
				{
					glVertex2f(-6, 3);
					glVertex2f(0, 0);
					glVertex2f(6, 3);
					glVertex2f(0, 1.5);
				}
				glEnd();
			}
			glEndList();

			glNewList(id + 1, GL_COMPILE);
			{
				glColor3f(0.0, 0.8, 0.0);
				glBegin(GL_LINES);
				{
					glVertex2f(-2, -5);
					glVertex2f(2, -5);
					glVertex2f(-4, -10);
					glVertex2f(4, -10);
					glVertex2f(-2, -15);
					glVertex2f(2, -15);
					glVertex2f(-5, -20);
					glVertex2f(5, -20);

					glVertex2f(0, -20);
					glVertex2f(0, 20);

					glVertex2f(-2, 5);
					glVertex2f(2, 5);
					glVertex2f(-4, 10);
					glVertex2f(4, 10);
					glVertex2f(-2, 15);
					glVertex2f(2, 15);
					glVertex2f(-5, 20);
					glVertex2f(5, 20);
				}
				glEnd();
			}
			glEndList();

		}
		glCallList(id);
		glCallList(id + 1);
		glRotatef(90, 0, 0, 1);
		glCallList(id + 1);
	}
	glPopMatrix();
}

} /* namespace object */
